<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled Document</title>
<!-- Bootstrap -->
<link
	href="<%=request.getContextPath()%>/styles/skin/new/css/bootstrap.css"
	rel="stylesheet">
<link
	href="<%=request.getContextPath()%>/styles/skin/new/css/custom.css"
	rel="stylesheet" type="text/css">
<link
	href="<%=request.getContextPath()%>/js/third/validator/css/validate.css"
	rel="stylesheet">

<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/i18n/i18n_zh.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/lib/WdatePicker.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/bootstrap.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/bootstrap.js"></script>
	<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/extends/jquery.jsonutil.js"></script>
<%@ include file="/pages/inc/taglibs.jsp"%>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
		  <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
		  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
		<![endif]-->
</head>
<body class="body">
	<nav class="navbar navbar-default navbar-fixed-top">
		<div class="container">
			<!-- Brand and toggle get grouped for better mobile display -->
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed"
					data-toggle="collapse" data-target="#topFixedNavbar1"
					aria-expanded="false">
					<span class="sr-only">Toggle navigation</span><span
						class="icon-bar"></span><span class="icon-bar"></span><span
						class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="#">
					<p class="Brand">
						<span style="color: #3399cc">Robo</span>Tax
					</p>
				</a>
			</div>
			<!-- Collect the nav links, forms, and other content for toggling -->
			<div class="collapse navbar-collapse" id="topFixedNavbar1">
				<ul class="nav navbar-nav">
					<li><a href="index.html">首页</a></li>
					<li><a href="#" class="link">产品</a></li>
					<li><a href="#">关于我们</a></li>
				</ul>
				<ul class="nav navbar-nav navbar-right">
					<li><a href="login.html">登录<span class="sr-only">(current)</span></a></li>
					<li><a href="register.html">注册</a></li>
				</ul>
			</div>
			<!-- /.navbar-collapse -->
		</div>
		<!-- /.container-fluid -->
	</nav>
	<div class="container-fluid registration">
		<div class="row">
			<button class="btn btn-primary" id="btnSubmit" >保存并提交</button>
			<label >                     </label>
			<label id="label-1">本周为:</label>
			<label id="weekNumber"></label>
		</div>
		<div class="row">
			<form id="timeSheetForm">
				<table id="timeSheetTable" class="table">
					<thead>
						<tr>
							<th>项目</th>
							<th>WBS</th>
							<th>周一</th>
							<th>周二</th>
							<th>周三</th>
							<th>周四</th>
							<th>周五</th>
							<th style="color:#FF0000">周六</th>
							<th style="color:#FF0000">周日</th>
						</tr>
					</thead>
					<tbody id="timeSheetBody">
						
					</tbody>
				</table>
			</form>
		</div>
	</div>

	<footer class="footer">
		<div class="container-fluid">
			<div class="row">
				<h3>Copyright &copy; Robotax</h3>
			</div>
		</div>

	</footer>
	<script type="text/javascript">
		$(document).ready(function() {
		
			initTimeSheetTableBody();
			
			var date = new Date();
			var weekNumber = getWeekNumber(date.getYear(), date.getMonth(), date.getDate());
			
			$("#weekNumber").html("第" + weekNumber + "周," + getStartOfCurrentWeek(date) + " - " + getEndOfCurrentWeek(date));

			
		});
		
		function formatDate(date) {
			var myyear = date.getFullYear();
			var mymonth = date.getMonth() + 1;
			var myweekday = date.getDate();

			if (mymonth < 10) {
				mymonth = "0" + mymonth;
			}
			if (myweekday < 10) {
				myweekday = "0" + myweekday;
			}
			return (myyear + "-" + mymonth + "-" + myweekday);
		}

		function getStartOfCurrentWeek(date) {
			var year = date.getFullYear();
			var month = date.getMonth();
			var day = date.getDate();
			var dayOfWeek = date.getDay();
			var weekStartDate = new Date(year, month, day
					- dayOfWeek + 1);
			return formatDate(weekStartDate);
		}

		function getEndOfCurrentWeek(date) {
			var year = date.getFullYear();
			var month = date.getMonth();
			var day = date.getDate();
			var dayOfWeek = date.getDay();
			var weekEndDate = new Date(year, month, day
					+ (7 - dayOfWeek));
			return formatDate(weekEndDate);
		}

		/**
		 * 判断年份是否为润年
		 *
		 * @param {Number} year
		 */
		function isLeapYear(year) {
			return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
		}

		/**
		 * 获取某一年份的某一月份的天数
		 *
		 * @param {Number} year
		 * @param {Number} month
		 */
		function getMonthDays(year, month) {
			return [ 31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ][month]
					|| (isLeapYear(year) ? 29 : 28);
		}

		/**
		 * 获取某年的某天是第几周
		 * @param {Number} y
		 * @param {Number} m
		 * @param {Number} d
		 * @returns {Number}
		 */
		function getWeekNumber(y, m, d) {
			var now = new Date(y, m - 1, d), year = now.getFullYear(), month = now
					.getMonth(), days = now.getDate();
			//那一天是那一年中的第多少天
			for (var i = 0; i < month; i++) {
				days += getMonthDays(year, i);
			}

			//那一年第一天是星期几
			var yearFirstDay = new Date(year, 0, 1).getDay() || 7;

			var week = null;
			if (yearFirstDay == 1) {
				week = Math.ceil(days / yearFirstDay);
			} else {
				days -= (7 - yearFirstDay + 1);
				week = Math.ceil(days / 7) + 1;
			}

			return week;
		}

		function initTimeSheetTableBody() {
			var row = $("#timeSheetBody").append("<tr  style='margin-top:2px;'></tr>");
			row.append("<td><select id='project'><option>A</option></select></td>");
			row.append("<td><select id='wps'><option>X</option></select></td>");

			row.append("<td><input id='day1' reg='^\d+$' tip_bak='只能为整数数字' /></td>");
			row.append("<td><input id='day2' /></td>");
			row.append("<td><input id='day3' /></td>");
			row.append("<td><input id='day4' /></td>");
			row.append("<td><input id='day5' /></td>");
			row.append("<td><input id='day6' /></td>");
			row.append("<td><input id='day7' /></td>");
		}
	</script>
	<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/third/validator/easy_validator.pack.js"></script>
</body>
</html>